package com.cocoiko.tools.facebook;

import android.content.SharedPreferences;

import com.cocoiko.FriendList.FriendsRequestListener;
import com.cocoiko.Setting.FacebookUserProfileListener;
import com.cocoiko.tools.twitter.Constants;
import com.cocoiko.utils.CocoikoConstains;
import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.Facebook;

public class FacebookUtils {

	/**
	 * 
	 * @param share
	 * @return
	 */
	static Facebook getFacebookInstant(SharedPreferences share) {

		Facebook facebook = new Facebook(CocoikoConstains.FACEBOOK_ID);
		if (SessionStore.restore(facebook, share))
			return facebook;
		return null;

	}

	/**
	 * 
	 * @param share
	 * @return
	 */
	public static boolean getFriendList(SharedPreferences share,
			FriendsRequestListener listener) {

		Facebook facebook = getFacebookInstant(share);
		if (facebook != null) {
			AsyncFacebookRunner runner = new AsyncFacebookRunner(facebook);
			runner.request("me/friends", listener);
			return true;
		}
		return false;

	}

	/**
	 * 
	 * @param share
	 * @param listener
	 * @return
	 */
	public static boolean getUserProfile(SharedPreferences share, FacebookUserProfileListener listener){
		
		Facebook facebook = getFacebookInstant(share);
		if(facebook != null){
			AsyncFacebookRunner runner = new AsyncFacebookRunner(facebook);
			runner.request("me", listener);
		}
		return false;
	}
	/**
	 * 
	 */
	/*
	public static boolean getUserProfilePicture(String id,
			SharedPreferences share, UserProfileListener listener) {

		Facebook facebook = getFacebookInstant(share);
		if (facebook != null) {
			AsyncFacebookRunner runner = new AsyncFacebookRunner(facebook);
			runner.request(id+"/picture", listener);
			return true;
		}
		return false;
		
	}
	*/

}
